package com.kingyea.mobilepolice.system.job;

import com.kingyea.app.market.area.controller.AreaController;
import com.kingyea.app.market.area.service.AreaService;
import com.kingyea.app.market.utils.GlobalVar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * GlobalJob
 *
 * @author Mr.Lin
 * @version v1.0.0
 * @description
 * @date Created in 2018/01/08 16:30
 */
@Component
//@PropertySource(value = {"classpath:application.properties"},encoding="UTF-8")// 依赖set方法
//@PropertySource(value = {"classpath:application.properties"},encoding="UTF-8")
public class GlobalJob {

    /**
     * 是否已经初始化
     */
    private boolean isInit = false;

    @Autowired
    private AreaService areaService;

    @Autowired
    private AreaController areaController;

//    @Value("${kingyea.market.isDev}")
//    private Boolean isDev;


    /**
     * 项目初始化
     **/
    @Scheduled(initialDelay = 10, fixedRate = 99999999)
    public void init() throws Exception {
        if (!isInit) {
            if (GlobalVar.getIsDev()) {
//                System.out.println(JSON.toJSONString(areaController.reload2Redis()));// 地区数据初始化，暂时无用
            }


            isInit = true;// 第一次初始化完成，之后不在执行这个方法
        }
    }


}
